import 'package:xinxuan/vo/common_vo/common_address_item_vo.dart';
import 'package:xinxuan/vo/common_vo/common_pagination_vo.dart';

class GiftOrderListVo {

  List<GiftOrderItem>? data;
  GiftOrderMeta? meta;

  GiftOrderListVo({this.data, this.meta});

  GiftOrderListVo.fromJson(Map<String, dynamic> json) {
    if (json['data'] != null) {
      data = [];
      json['data'].forEach((v) {
        data!.add(new GiftOrderItem.fromJson(v));
      });
    }
    meta = json['meta'] != null ? new GiftOrderMeta.fromJson(json['meta']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.data != null) {
      data['data'] = this.data!.map((v) => v.toJson()).toList();
    }
    if (this.meta != null) {
      data['meta'] = this.meta!.toJson();
    }
    return data;
  }
}

class GiftOrderItem {
  int? id;
  String? orderSn;
  int? userId;
  String? statusStr;
  int? status;
  String? payAmount;
  String? totalAmount;
  int? expressId;
  String? expressCompany;
  String? expressSn;
  String? expressPrice;
  String? shippingStatusStr;
  int? shippingStatus;
  String? outTradeNo;
  String? createdAt;
  CommonAddressItem? address;
  List<ProductsItem>? products;

  GiftOrderItem(
      {this.id,
      this.orderSn,
      this.userId,
      this.statusStr,
      this.status,
      this.payAmount,
      this.totalAmount,
      this.expressId,
      this.expressCompany,
      this.expressSn,
      this.expressPrice,
      this.shippingStatusStr,
      this.shippingStatus,
      this.outTradeNo,
      this.createdAt,
      this.address,
      this.products});

  GiftOrderItem.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    orderSn = json['order_sn'];
    userId = json['user_id'];
    statusStr = json['status_str'];
    status = json['status'];
    payAmount = json['pay_amount'];
    totalAmount = json['total_amount'];
    expressId = json['express_id'];
    expressCompany = json['express_company'];
    expressSn = json['express_sn'];
    expressPrice = json['express_price'];
    shippingStatusStr = json['shipping_status_str'];
    shippingStatus = json['shipping_status'];
    outTradeNo = json['out_trade_no'];
    createdAt = json['created_at'];
    address =
        json['address'] != null ? new CommonAddressItem.fromJson(json['address']) : null;
    if (json['products'] != null) {
      products = [];
      json['products'].forEach((v) {
        products!.add(new ProductsItem.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['order_sn'] = this.orderSn;
    data['user_id'] = this.userId;
    data['status_str'] = this.statusStr;
    data['status'] = this.status;
    data['pay_amount'] = this.payAmount;
    data['total_amount'] = this.totalAmount;
    data['express_id'] = this.expressId;
    data['express_company'] = this.expressCompany;
    data['express_sn'] = this.expressSn;
    data['express_price'] = this.expressPrice;
    data['shipping_status_str'] = this.shippingStatusStr;
    data['shipping_status'] = this.shippingStatus;
    data['out_trade_no'] = this.outTradeNo;
    data['created_at'] = this.createdAt;
    if (this.address != null) {
      data['address'] = this.address!.toJson();
    }
    if (this.products != null) {
      data['products'] = this.products!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class ProductsItem {
  int? orderId;
  int? productId;
  String? title;
  String? image;
  String? price;
  int? quantity;

  ProductsItem(
      {this.orderId,
      this.productId,
      this.title,
      this.image,
      this.price,
      this.quantity});

  ProductsItem.fromJson(Map<String, dynamic> json) {
    orderId = json['order_id'];
    productId = json['product_id'];
    title = json['title'];
    image = json['image'];
    price = json['price'];
    quantity = json['quantity'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['order_id'] = this.orderId;
    data['product_id'] = this.productId;
    data['title'] = this.title;
    data['image'] = this.image;
    data['price'] = this.price;
    data['quantity'] = this.quantity;
    return data;
  }
}

class GiftOrderMeta {
  CommonPagination? pagination;

  GiftOrderMeta({this.pagination});

  GiftOrderMeta.fromJson(Map<String, dynamic> json) {
    pagination = json['pagination'] != null
        ? new CommonPagination.fromJson(json['pagination'])
        : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.pagination != null) {
      data['pagination'] = this.pagination!.toJson();
    }
    return data;
  }
}
